$(function () {
    var options = {
        toolbar: "#qtpz_import_content_toolbar",
        fitColumns: true,
        fit: true,
        singleSelect: true,
        checkbox: true,
        checkOnSelect: false,
        selectOnCheck: false,
        rownumbers: true,
        showFooter: true,
        autoRowHeight: true,
        nowrap: false,
        columns: [
            [
                {field: 'zy', title: '摘要', width: 50, align: 'center'},
                {field: 'kmmc', title: '科目', width: 50, align: 'center'},
                {field: 'jfje', title: '借方', width: 30, align: 'right', formatter: function (value) {
                    var sl = formatJe2(value, ",");
                    return sl;
                }},
                {field: 'dfje', title: '贷方', width: 30, align: 'right', formatter: function (value) {
                    var sl = formatJe2(value, ",");
                    return sl;
                }},
                {field: 'fzhs', title: '辅助核算', width: 50, align: 'center', formatter: formatColumn}
            ]
        ],
        url: $.webPath() + '/cwgl/qtpz/findQtpzfl',
        queryParams: {id: $("#qtpz_import_content_toolbar [name='qtpz.id']").val()}
    };

    var grid = $('#qtpz_import_content_datagrid').edatagrid(options);

    function formatColumn(value, row, index) {
        if (typeof(value) == "undefined" || value.length == 0)
            return "";
        var items = [];
//        if ($.trim(value) != "")
//            items = value.split("；");
        var temp = "";
        items = new Array();
        var regexpArray = [/客户/, /供应商/, /部门/, /个人/, /项目/];
        var regexpText = ["客户", "供应商", "部门", "职员", "项目核算"];
        for (var r = 0; r < regexpArray.length; r++) {
            if (value.search(regexpArray[r]) != -1)
                items.push(regexpText[r]);
        }
        if (items.length != 0) {
            for (var i = 0; i < items.length; i++) {
                temp += row["fzhsList[" + i + "].code"] == "" || row["fzhsList[" + i + "].code"] == undefined
                    ? "" : "<p>" + items[i] + ":" + row["fzhsList[" + i + "].code"] + "_" + row["fzhsList[" + i + "].name"] + "</p>";
            }
            return temp;
        } else
            return "";
    }
});
